<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
    <input type="hidden" name="row[scenario]" value="add">
    {if condition="!$shopId"}
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('限定门店')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-shop_ids" class="form-control selectpage" type="text"  name="row[shop_ids]" title="" data-multiple="true" data-source="yunfood/shop/main/index">
        </div>
    </div>
    {else /}
    <input type="hidden" name="row[shop_ids]" value="{$shopId}">
    {/if}
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('名称')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-name" class="form-control" type="text" name="row[name]" title="" data-rule="required">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('分类')}:</label>
        <div class="col-xs-12 col-sm-8">
            {:build_select('row[category_id]', $categoryList, null, ['class'=>'form-control selectpicker'])}
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('封面')}:</label>
        <div class="col-xs-12 col-sm-8">
            <div class="input-group">
                <input id="c-cover_url" class="form-control" type="text"  name="row[cover_url]" value="" title="" data-rule="required">
                <div class="input-group-addon no-border no-padding">
                    <span><button type="button" id="faupload-cover_url" class="btn btn-danger faupload" data-input-id="c-cover_url" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="false" data-preview-id="p-cover_url"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
                    <span><button type="button" id="fachoose-cover_url" class="btn btn-primary fachoose" data-input-id="c-cover_url" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
                </div>
                <span class="msg-box n-right" for="c-cover_url"></span>
            </div>
            <ul class="row list-inline faupload-preview" id="p-cover_url"></ul>
        </div>
    </div>
    <div class="form-group">
        <label for="c-photos" class="control-label col-xs-12 col-sm-2">{:__('图集')}:</label>
        <div class="col-xs-12 col-sm-8">
            <div class="input-group">
                <input id="c-photos" data-rule="required" class="form-control" size="50" name="row[photos]" value="" type="text">
                <div class="input-group-addon no-border no-padding">
                    <span><button type="button" id="faupload-photos" class="btn btn-danger faupload" data-input-id="c-photos" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="true" data-preview-id="p-photos"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
                    <span><button type="button" id="fachoose-photos" class="btn btn-primary fachoose" data-input-id="c-photos" data-mimetype="image/*" data-multiple="true"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
                </div>
                <span class="msg-box n-right" for="c-photos"></span>
            </div>
            <ul class="row list-inline faupload-preview" id="p-photos"></ul>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('多规格')}:</label>
        <div class="col-xs-12 col-sm-2">
            <input  id="c-multi_spec" name="row[multi_spec]" type="hidden" value="0">
            <a href="javascript:;" data-toggle="switcher" class="btn-switcher" data-input-id="c-multi_spec" data-yes="1" data-no="0" >
                <i class="fa fa-toggle-on text-success fa-flip-horizontal text-gray fa-2x"></i>
            </a>
        </div>
    </div>
    <div class="form-group hide" id="box-sku">
        <label class="control-label col-xs-12 col-sm-2">{:__('规格值')}:</label>
        <div class="col-xs-12 col-sm-8">
            <table id="c-specData-table" class="table fieldlist" data-template="spectpl" data-name="row[specData]" data-type="2">
                <tr>
                    <th width="136">{:__('名称')}</th>
                    <th>{:__('规格')}</th>
                    <th width="84"></th>
                </tr>
                <tr>
                    <td colspan="3">
                        <a href="javascript:;" class="btn btn-sm btn-success btn-append"><i class="fa fa-plus"></i> {:__('增加规格')}</a>
                        <a href="javascript:;" class="btn btn-sm btn-primary choose-spec"><i class="fa fa-list"></i> {:__('选择规格')}</a>
                    </td>
                </tr>
            </table>
            <textarea id="c-specData" class="form-control" name="row[specData]" title="" cols="30" rows="5" style="display: none;">[]</textarea>
            <script id="spectpl" type="text/html">
                <tr class="form-inline">
                    <td><input class="form-control c-sku-name" type="text" name="<%=name%>[<%=index%>][name]" value="<%=row.name%>" title="" placeholder="" style="width: 80px"/></td>
                    <td>
                        <input class="form-control" type="text" name="<%=name%>[<%=index%>][items]" value="<%=row.items%>" title="" data-role="tagsinput" />
                    </td>
                    <td>
                        <input type="hidden" name="<%=name%>[<%=index%>][id]" value="<%=row.id%>" title=""/>
                        <span class="btn btn-sm btn-danger btn-remove"><i class="fa fa-times"></i></span>
                        <span class="btn btn-sm btn-success btn-save-spec"><i class="fa fa-save"></i></span>
                    </td>
                </tr>
            </script>
            <table id="c-skuData-table" class="table fieldlist hide" data-template="skutpl" data-name="row[skuData]" data-type="2">
                <tr id="sku-head">
                    <th id="sku-mid">{:__('图片')}</th>
                    <th width="116">{:__('原价')}</th>
                    <th width="116">{:__('售价')}</th>
                    <th width="96">{:__('库存')}</th>
                    <th width="84">操作</th>
                </tr>
                <tr>
                    <td id="sku-blank" colspan="1">
                        <a href="javascript:;" class="btn btn-sm btn-success btn-append hide"><i class="fa fa-plus"></i> {:__('增加SKU')}</a>
                    </td>
                    <td><input id="multi-market-price" class="form-control" type="number" title="" placeholder="" style="width: 100px"/></td>
                    <td><input id="multi-price" class="form-control" type="number" title="" placeholder="" style="width: 100px"/></td>
                    <td><input id="multi-count-left" class="form-control" type="number" title="" placeholder="" style="width: 80px"/></td>
                    <td>
                        <span class="btn btn-sm btn-success btn-multi-set"><i class="fa fa-copy"></i> 批量设置</span>
                    </td>
                </tr>
            </table>
            <textarea id="c-skuData" class="form-control" name="row[skuData]" title="" cols="30" rows="5" style="display: none;">[]</textarea>
            <script id="skutpl" type="text/html">
                <tr class="form-inline">
                    <%for(var i = 0; i < row.spec_items.length; i++){%>
                    <td rowspan="<%=row.spec_items[i].rowspan%>" style="vertical-align: middle;">
                        <%=row.spec_items[i].name%>
                    </td>
                    <%}%>
                    <td>
                        <img class="c-sku-item-cover-preview" src="<%=Fast.api.cdnurl(row.cover_url)%>" alt="" style="max-height: 50px; display: block; text-align: center; margin-bottom: 10px;">
                        <!--@formatter:off-->
                        <input class="c-sku-item-cover" type="hidden" name="<%=name%>[<%=index%>][cover_url]" id="c-cover_url-<%=index%>" value="<%=row.cover_url%>">
                        <button type="button" id="faupload-cover_url-<%=index%>" class="btn btn-xs btn-danger faupload upload-image" data-input-id="c-cover_url-<%=index%>" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp,image/webp" data-multiple="false"><i class="fa fa-upload"></i> {:__('Upload')}</button>
                        <!--@formatter:on-->
                        <button type="button" id="fachoose-cover_url-<%=index%>" class="btn btn-xs btn-primary fachoose" data-input-id="c-cover_url-<%=index%>" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button>
                    </td>
                    <td><input class="form-control" type="number" name="<%=name%>[<%=index%>][market_price]" value="<%=row.market_price%>" title="" placeholder="" style="width: 100px"/></td>
                    <td><input class="form-control" type="number" name="<%=name%>[<%=index%>][price]" value="<%=row.price%>" title="" placeholder="" style="width: 100px"/></td>
                    <td>
                        <input class="form-control" type="number" name="<%=name%>[<%=index%>][count_left]" value="<%=row.count_left%>" title="" placeholder="" style="width: 80px"/>
                    </td>
                    <td>
                        <input id="c-status-<%=index%>" class="form-control" type="hidden" name="<%=name%>[<%=index%>][status]" value="1" title="" style="width:100px"/>
                        <a href="javascript:" data-toggle="switcher" class="btn-switcher" data-input-id="c-status-<%=index%>" data-yes="1" data-no="2" >
                            <i class="fa fa-toggle-on fa-2x <%if(row.status==1){%>text-success<%}else{%>text-success fa-flip-horizontal text-gray<%}%>"></i>
                        </a>
                        <input type="hidden" name="<%=name%>[<%=index%>][id]" value="<%=row.id%>" title=""/>
                        <input type="hidden" name="<%=name%>[<%=index%>][spec_text]" value="<%=row.spec_text%>" title=""/>
                        <input type="hidden" name="<%=name%>[<%=index%>][spec_data]" value="<%=row.spec_data%>" title=""/>
                    </td>
                </tr>
            </script>
        </div>
    </div>
    <div class="form-group hide" id="box-price">
        <label class="control-label col-xs-12 col-sm-2">{:__('售价')}:</label>
        <div class="col-xs-12 col-sm-3">
            <input id="c-price" class="form-control" type="number" name="row[price]" title="">
        </div>
        <label class="control-label col-xs-12 col-sm-2">{:__('原价')}:</label>
        <div class="col-xs-12 col-sm-3">
            <input id="c-market_price" class="form-control" type="number" name="row[market_price]" title="">
        </div>
    </div>
    <div class="form-group hide" id="box-count_left">
        <label class="control-label col-xs-12 col-sm-2">{:__('库存')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-count_left" class="form-control" type="number" name="row[count_left]" title="">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('其他属性')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-attr_ids" class="form-control selectpage" type="text"  name="row[attr_ids]" title="" data-multiple="true" data-source="yunfood/food/param/index?type=attr">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('可选备注')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-note_ids" class="form-control selectpage" type="text"  name="row[note_ids]" title="" data-multiple="true" data-source="yunfood/food/param/index?type=note">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('可加菜品')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-addon_ids" class="form-control selectpage" type="text"  name="row[addon_ids]" title="" data-multiple="true" data-source="yunfood/food/param/index?type=addon">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('备注')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-note" class="form-control" type="text" name="row[note]" title="">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('权重')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-weight" class="form-control" type="number" name="row[weight]" title="">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
        <div class="col-xs-12 col-sm-8">
            {:build_radios('row[status]', $statusList, null, ['class'=>'form-control selectpicker'])}
        </div>
    </div>
    <div class="form-group layer-footer">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 col-sm-8">
            <button class="btn btn-success btn-embossed disabled" type="submit">{:__('OK')}</button>
            <button class="btn btn-default btn-embossed" type="reset">{:__('Reset')}</button>
        </div>
    </div>
</form>